﻿Imports Microsoft.DirectX.Direct3D

Namespace Libs

    Module mImageLibrarys

        'Public EvoLogo As Texture

        Public sDataPath As String = "D:\MirEvo-MAIN\MirEvoClient\EvoClient\Data"

        Public Interface1c As MirImageLibrary
        Public GameInter As MirImageLibrary
        
        Public TileSC As MirImageLibrary
        Public Tiles5C As MirImageLibrary
        Public TileS30C As MirImageLibrary
        Public SMTileSC As MirImageLibrary
        Public HouseSC As MirImageLibrary
        Public CliffSC As MirImageLibrary
        Public DungeonSC As MirImageLibrary
        Public InnerSC As MirImageLibrary
        Public FurnitureSC As MirImageLibrary
        Public WallSC As MirImageLibrary
        Public SMObjectSC As MirImageLibrary
        Public AnimationSC As MirImageLibrary
        Public Object1C As MirImageLibrary
        Public Object2C As MirImageLibrary

        Public WoodTileSC As MirImageLibrary
        Public WoodTiles5C As MirImageLibrary
        Public WoodHouseSC As MirImageLibrary
        Public WoodCliffSC As MirImageLibrary
        Public WoodFurnitureSC As MirImageLibrary
        Public WoodSMObjectSC As MirImageLibrary
        Public WoodDungeonSC As MirImageLibrary
        Public WoodInnerSC As MirImageLibrary

        Public Equip As MirImageLibrary
        Public ProgUse As MirImageLibrary

        Public MonImg As MirImageLibrary

        Public Mon1 As MirImageLibrary
        Public MonS1 As MirImageLibrary


        Public Inventory As MirImageLibrary
        Public Ground As MirImageLibrary

        Public NPC As MirImageLibrary
        Public Avatar As MirImageLibrary

        Public Editor As MirImageLibrary

        Public Sub Init()

            'EvoLogo = TextureLoader.FromFile(DirectX.D3D, sDataPath & "evologo.png", 0, 0, 0, 0, _
            '            Format.A8R8G8B8, Pool.Managed, Filter.None, Filter.None, Color.FromArgb(255, 0, 0, 0).ToArgb())

            'Interface1c = New MirImageLibrary(sDataPath & "Interface1c.mil")
            'GameInter = New MirImageLibrary(sDataPath & "GameInter.mil")

            'Inventory = New MirImageLibrary(sDataPath & "inventory.mil")
            'Equip = New MirImageLibrary(sDataPath & "Equip.mil")
            'ProgUse = New MirImageLibrary(sDataPath & "ProgUse.mil")

            'MonImg = New MirImageLibrary(sDataPath & "MonImg.mil")

            'Mon1 = New MirImageLibrary(sDataPath & "Mon-3.mil")

            'MonS1 = New MirImageLibrary(sDataPath & "MonS-3.mil")

            TileSC = New MirImageLibrary("Tilesc")
            TileS30C = New MirImageLibrary("Tiles30c")
            Tiles5C = New MirImageLibrary("tiles5c")
            SMTileSC = New MirImageLibrary("smtilesc")
            HouseSC = New MirImageLibrary("Housesc")
            CliffSC = New MirImageLibrary("Cliffsc")
            DungeonSC = New MirImageLibrary("dungeonsc")
            InnerSC = New MirImageLibrary("innersc")
            FurnitureSC = New MirImageLibrary("furnituresc")
            WallSC = New MirImageLibrary("wallsc")
            SMObjectSC = New MirImageLibrary("SMObjectsc")
            Object1C = New MirImageLibrary("Object1c")
            Object2C = New MirImageLibrary("Object2c")


            WoodTileSC = New MirImageLibrary("wood\Tilesc")

            WoodTiles5C = New MirImageLibrary("wood\tiles5c")
            WoodHouseSC = New MirImageLibrary("wood\Housesc")
            WoodCliffSC = New MirImageLibrary("wood\Cliffsc")

            WoodDungeonSC = New MirImageLibrary("wood\dungeonsc")

            WoodFurnitureSC = New MirImageLibrary("Wood\Furnituresc")

            WoodSMObjectSC = New MirImageLibrary("wood\smobjectsc")
            WoodInnerSC = New MirImageLibrary("wood\innersc")
            AnimationSC = New MirImageLibrary("Animationsc")

            NPC = New MirImageLibrary("NPC")
            Avatar = New MirImageLibrary("MonImg")

            Editor = New MirImageLibrary("editor", , True)

        End Sub

        Public Sub LoadUILibs()

            Inventory = New MirImageLibrary("Inventory", True)
            Ground = New MirImageLibrary("Ground", True)

        End Sub

        Public Sub DisposeUILibs()

            Inventory.Dispose()
            Ground.Dispose()

        End Sub

        Public Sub Shutdown()

            'Interface1c.Dispose()
            'GameInter.Dispose()

            'Inventory.Dispose()
            'Equip.Dispose()
            'ProgUse.Dispose()

            'MonImg.Dispose()

            'Mon1.Dispose()
            'MonS1.Dispose()

            TileSC.Dispose()
            Tiles5C.Dispose()
            TileS30C.Dispose()
            SMTileSC.Dispose()
            HouseSC.Dispose()
            CliffSC.Dispose()
            DungeonSC.Dispose()
            InnerSC.Dispose()
            FurnitureSC.Dispose()
            WallSC.Dispose()
            SMObjectSC.Dispose()
            'AnimationSC.Dispose()
            Object1C.Dispose()
            Object2C.Dispose()

            WoodTileSC.Dispose()
            WoodTiles5C.Dispose()
            WoodHouseSC.Dispose()
            WoodCliffSC.Dispose()
            WoodFurnitureSC.Dispose()
            WoodSMObjectSC.Dispose()
            WoodDungeonSC.Dispose()
            WoodInnerSC.Dispose()

            NPC.Dispose()
            Avatar.Dispose()

            Editor.Dispose()

        End Sub

        Public Function GetLib(ByRef imglib As Protocol.ImgLibs) As MirImageLibrary

            Select Case imglib
                Case Protocol.ImgLibs.Interface1c
                    Return Interface1c
                Case Protocol.ImgLibs.GameInter
                    Return GameInter
                Case Protocol.ImgLibs.Inventory
                    Return Inventory
                Case Protocol.ImgLibs.Equip
                    Return Equip
                Case Protocol.ImgLibs.ProgUse
                    Return ProgUse

                Case Protocol.ImgLibs.MonImg
                    Return MonImg

                Case Protocol.ImgLibs.Mon1
                    Return Mon1

                Case Protocol.ImgLibs.MonS1
                    Return MonS1


                Case EvoLib.Protocol.ImgLibs.TileSC
                    Return TileSC
                Case EvoLib.Protocol.ImgLibs.Tiles5C
                    Return Tiles5C
                Case EvoLib.Protocol.ImgLibs.TileS30C
                    Return TileS30C
                Case EvoLib.Protocol.ImgLibs.HouseSC
                    Return HouseSC
                Case EvoLib.Protocol.ImgLibs.CliffSC
                    Return CliffSC
                Case EvoLib.Protocol.ImgLibs.SMObjectSC
                    Return SMObjectSC
                Case EvoLib.Protocol.ImgLibs.SmTileSC
                    Return SMTileSC
                Case EvoLib.Protocol.ImgLibs.DungeonSC
                    Return DungeonSC
                Case EvoLib.Protocol.ImgLibs.InnerSC
                    Return InnerSC
                Case EvoLib.Protocol.ImgLibs.FurnitureSC
                    Return FurnitureSC
                Case EvoLib.Protocol.ImgLibs.WallSC
                    Return WallSC
                Case EvoLib.Protocol.ImgLibs.WoodTiles5C
                    Return WoodTiles5C
                Case EvoLib.Protocol.ImgLibs.WoodFurnitureSC
                    Return WoodFurnitureSC
                Case EvoLib.Protocol.ImgLibs.WoodSMObjectSC
                    Return WoodSMObjectSC
                Case EvoLib.Protocol.ImgLibs.WoodDungeonSC
                    Return WoodDungeonSC
                Case EvoLib.Protocol.ImgLibs.WoodInnerSC
                    Return WoodInnerSC
                Case EvoLib.Protocol.ImgLibs.Objects1C
                    Return Object1C
                Case EvoLib.Protocol.ImgLibs.Object2C
                    Return Object2C
                Case EvoLib.Protocol.ImgLibs.WoodTileSC
                    Return WoodTileSC
                Case EvoLib.Protocol.ImgLibs.WoodHouseSC
                    Return WoodHouseSC
                Case EvoLib.Protocol.ImgLibs.WoodCliffSC
                    Return WoodCliffSC
                Case EvoLib.Protocol.ImgLibs.AnimationSC
                    Return AnimationSC
                Case EvoLib.Protocol.ImgLibs.NPC
                    Return NPC

                Case Else
                    Throw New Exception("imglib was invalid")
            End Select

        End Function

        Public Structure LibShapePair
            Dim library As Protocol.ImgLibs
            Dim shape As Integer
        End Structure

        Public Function GetMobLib(ByRef shape As Integer) As LibShapePair

            Dim ret As New LibShapePair

            Select Case shape

                Case 0 To 10
                    ret.shape = shape
                Case 11 To 21
                    ret.shape = shape - 11
                Case 22 To 32
                    ret.shape = shape - 22
                Case 33 To 43
                    ret.shape = shape - 33
                Case 44 To 54
                    ret.shape = shape - 44
                Case 55 To 65
                    ret.shape = shape - 55
                Case 66 To 76
                    ret.shape = shape - 66
                Case 77 To 87
                    ret.shape = shape - 77
                Case 88 To 98
                    ret.shape = shape - 88
                Case 99 To 109
                    ret.shape = shape - 99
                Case 110 To 120
                    ret.shape = shape - 110
                Case 121 To 131
                    ret.shape = shape - 121
                Case 132 To 142
                    ret.shape = shape - 132

            End Select

            Select Case shape
                Case 0 To 10
                    ret.library = Protocol.ImgLibs.Mon1
                Case 11 To 21
                    'ret.library = Protocol.ImgLibs.MWeapon2
                Case 22 To 32
                    'ret.library = Protocol.ImgLibs.MWeapon3
                Case 33 To 43
                    'ret.library = Protocol.ImgLibs.MWeapon4
                Case 44 To 54
                    'ret.library = Protocol.ImgLibs.MWeapon5
                Case 55 To 65
                    'ret.library = Protocol.ImgLibs.MWeapon6
                Case 66 To 76
                    'ret.library = Protocol.ImgLibs.MWeapon7
                Case 77 To 87
                    'ret.library = Protocol.ImgLibs.MWeapon10
                Case 88 To 98
                    'ret.library = Protocol.ImgLibs.MWeapon11
                Case 99 To 109
                    'ret.library = Protocol.ImgLibs.MWeaponADL1
                Case 110 To 120
                    'ret.library = Protocol.ImgLibs.MWeaponADR1
                Case 121 To 131
                    'ret.library = Protocol.ImgLibs.MWeaponAOH1
                Case 132 To 142
                    'ret.library = Protocol.ImgLibs.MWeaponAOH2
            End Select

            Return ret

        End Function

    End Module

End Namespace

